package com.sky.controller.admin;

import com.sky.dto.DishPageQueryDTO;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/admin/setmeal")
@RequiredArgsConstructor
public class SetmealController {
    private final SetmealService setmealService;

    /**
     * 页
     *
     * @param setmealPageQueryDTO 套餐页面查询dto
     * @return {@link Result}<{@link PageResult}>
     */
    @GetMapping("/page")
    public Result<PageResult> page(SetmealPageQueryDTO setmealPageQueryDTO) {
        PageResult pageResult = setmealService.page(setmealPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 回声套餐
     *
     * @param id id
     * @return {@link Result}<>
     */
    @GetMapping("/{id}")
    public Result<SetmealVO> echoSetmeal(@PathVariable Long id) {
        SetmealVO setmealVO = setmealService.echoSetmeal(id);
        return Result.success(setmealVO);
    }

    /**
     * 添加套餐
     *
     * @param setmeal 客饭
     * @return {@link Result}<{@link PageResult}>
     */
    @PostMapping
    public Result<?> addSetmeal(@RequestBody SetmealDTO setmeal) {
        setmealService.addSetmeal(setmeal);
        return Result.success();
    }

    /**
     * 更新状态
     *
     * @param id     id
     * @param status 地位
     * @return {@link Result}<{@link ?}>
     */
    @PostMapping("/status/{status}")
    public Result<?> updateStatus(Long id,@PathVariable Integer status) {
        setmealService.updateStatus(id,status);
        return Result.success();
    }

    /**
     * 删除套餐
     *
     * @param ids ids
     * @return {@link Result}<{@link ?}>
     */
    @DeleteMapping
    public Result<?> deleteSetmeal(@RequestParam List<Long> ids) {
        setmealService.deleteSetmeal(ids);
        return Result.success();
    }

    /**
     * 套餐
     *
     * @param ids ids
     * @return {@link Result}<{@link ?}>
     */
    @PutMapping
    public Result<?> updateSetmeal(@RequestBody SetmealDTO setmeal) {
        setmealService.updateSetmeal(setmeal);
        return Result.success();
    }
}
